﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using pay.DAL.IDAL;
using pay.DAL;
using pay.Entity;

namespace pay.BLL
{
    public class OrderBLL
    {
        IOrderDAL orderDAL = new OrderDAL();
        OrderDetailDAL orderDetailDAL=new OrderDetailDAL ();
        public pay.Entity.Web_Order GetOrderByOrderNumber(string orderNumber)
        {
            OrderQuery oq = new OrderQuery();
            oq.Sign = 0;
            oq.Id = 0;
            oq.Username = "";
            oq.Where = "";
            oq.OrderNumber = orderNumber;
            return orderDAL.GetOrderByOrdernumber(oq);
        }

        public bool Add(pay.Entity.Web_Order order,pay.Entity.OrderDetail [] oDetails)
        {
            foreach (var c in oDetails)
            {
                if (orderDetailDAL.Add(c) < 0)
                {
                    return false;
                }
            }
            if (orderDAL.Add(order) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #region IOrderBLL 成员

        //更新订单状态
        public bool UpdateOrderSucess(string orderNumber)
        {
            if (orderDAL.UpdateOrderSatus(orderNumber, 5) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion
    }
}
